using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ReportUtility.Utils
{
    public class Log
    {
        static StreamWriter writer;

        static StreamWriter GetWriter()
        {
            if (writer == null)
            {
                writer = new StreamWriter(Path.Combine("./", DateTime.Today.ToString("yyyy-MM-dd")), true, Consts.File_Encoding);
            }
            return writer;

        }

        public static void Error(string errStr)
        {
            try
            {
                GetWriter().Write("[Error]" + DateTime.Today.ToLongTimeString());
                GetWriter().WriteLine(errStr);
                GetWriter().Flush();
            }
            catch{
            }
        }

        public static void Info(string info)
        {
            try
            {
                GetWriter().Write("[Info]" + DateTime.Today.ToLongTimeString());
                GetWriter().WriteLine(info);
                GetWriter().Flush();
            }
            catch
            {
            }
        }
    }
}
